<?php

	require_once ("../libraryfiles/config.php");
       // Change Layout
        $user = mysql_query("SELECT * FROM tbluser WHERE email='".$_SESSION['username']."'");
        $user_ck = mysql_fetch_assoc($user);
		
  if(isset($_POST['s_layout']))
    {
    	$col_style = mysql_query("UPDATE tbl_style SET columns='".$_POST['layout']."' where by_company_id='".$user_ck['id']."'");
        if($col_style)
        {
            header("location:edit.php?message=Your Layout has been change already!"); 
        }  
        else
        {
        	header("location:edit.php?message=Your Layout cannot be change");
        }
    }

		// end Change Layout

if(isset($_POST['chage_b_header'])){
$allowedExts = array("jpg", "jpeg", "gif", "png");
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))) {


        move_uploaded_file($_FILES["file"]["tmp_name"],
      	"uploads/" . $_FILES["file"]["name"]);
        $filename=$_FILES['file']['name'];
        
        //check first
        $ch_style = mysql_query("SELECT * FROM tbl_style WHERE by_company_id='".$user_ck['id']."'");
        if(dbNumRows($ch_style)){             
                $image_style = mysql_query("UPDATE tbl_style SET images='".$filename."' where by_company_id='".$user_ck['id']."'");
            }
            else
            {                
                $image_style = mysql_query("INSERT INTO tbl_style (by_company_id,images,type_img, sitename, site_tagline, timezone, language) VALUE('".$user_ck['id']."','$filename',1, 'Your site name', 'discription of your site', 'UTC+7','en')");
            }
            
        //end check        			
		$_SESSION['id']=$sel_assoc["id"];
		$image_name=$sel_assoc['images'];
        $_SESSION['message'] = 'Change successfully!';
        header("location:action/?p=setting/index");
  }
  else
  {
    header("location:edit.php?message=This file not allow to upload!");
  }
}

// change category
if(isset($_POST['edit_cat']))
      {
        $cat_user = mysql_query ("UPDATE tbluser SET cat_id='".$_POST['edit_cat']."' WHERE email='".$_SESSION['username']."'");      
        header("Location:../company/product/index.php?view=add");
      }
      
if(isset($_POST['sub_s_contact']))      
{
    $s_con_d = mysql_query("UPDATE tblpharmacy SET contact='".$_POST['s_contact']."' WHERE user_id='".$_SESSION['acc_id']."'");
    if($s_con_d)
    {
        header("Location:company/dashboard/index.php?success=Your concact has been change!&class=success");
    }
    else
    {
        header("Location:company/dashboard/index.php?success=Your concact connot change!&class=success");
    }

}
?>